####################################################################################
## xu xian feng
## 2023/04/15
## STAD analysis
####################################################################################

source ~/20220915_gastric_multiple/dna_combinePublic/config/config.sh
export config_file=~/20220915_gastric_multiple/dna_combinePublic/config/config.sh

mkdir -p ${work_dir}/finalPlot
mkdir -p ${work_dir}/finalPlot/Plot_Article/

####################################################################################
## 第一部分
## 研究设计 + 基线特征 + 分子特征
####################################################################################
mkdir -p ${work_dir}/finalPlot/study_design/
mkdir -p ${work_dir}/finalPlot/molecular_type/
mkdir -p ${work_dir}/finalPlot/Plot_Article/Part1

##########################################
## 模式图
## 1、不同分子亚型突变负荷
${Rscript} ${scripts_path}/plot/mutBurden.MolecularType.mode.R \
--input_file ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv \
--out_path ${work_dir}/finalPlot/study_design

## 2、肠化的TMB和饮酒
${Rscript} ${scripts_path}/mutBurden/mutBurden_plot.Baseline.mode.R \
--input_file ${baseTable_path}/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--images_path ${work_dir}/finalPlot/study_design

## 3、突变瀑布图
${Rscript} ${scripts_path}/plot/waterfull_smg.new_v2.mode.R \
--maf_path ${maf_public_path} \
--images_path ${work_dir}/finalPlot/study_design/ \
--info_file ${config_path}/tumor_normal.class.list \
--info_public_file ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv \
--class_order_file ${config_path}/Class_order.list \
--im_list ${mutsig_check_path}/im_smg.list \
--igc_list ${mutsig_check_path}/igc_smg.addEvolution.list \
--dgc_list ${mutsig_check_path}/dgc_smg.addEvolution.list

## 4、进化模式
clone_t=0.6
choose_rate=0
class_type_list=("IGC" "DGC")
for class_type in ${class_type_list[@]}
do
## 驱动基因的共享和私有情况
${Rscript} ${scripts_path}/plot/JudgeGeneDriverSharePrivate.mode.R \
--muti_cancer ${maf_path}/All_GGA.cancer.maf \
--muti_pre ${maf_path}/All_GGA.precancer.maf \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.tsv \
--gene_list ${mutsig_check_path}/smg.list  \
--sample_info ${config_path}/tumor_normal.class.list \
--type ${class_type} \
--clone_t ${clone_t} \
--choose_rate ${choose_rate} \
--out_path ${work_dir}/finalPlot/study_design
done


##########################################
## 比较不同来源样本的基线，产生对应的附表1（STAD-CombinePublic.BaseLineCompare.csv）
${Rscript_mutationTime} ${scripts_path}/finalPlot/CompareBaseLine.CombinePublic.R \
--input_file ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv \
--nmu_file ${config_path}/STAD_MutipleReigon_baseline.addAlcoholFreq.tsv \
--out_dir ${work_dir}/finalPlot/study_design/


##########################################
## 统计IM，IGC和DGC各自的样本量
## WES
IM_sample_num=`cat ${config_path}/tumor_normal.class.MSS_MSI.list | grep IM- | wc -l`
IGC_sample_num=`cat ${config_path}/tumor_normal.class.MSS_MSI.list | grep IGC- | wc -l`
DGC_sample_num=`cat ${config_path}/tumor_normal.class.MSS_MSI.list | grep DGC- | wc -l`

echo "IM_sample_num,IGC_sample_num,DGC_sample_num"
echo ${IM_sample_num},${IGC_sample_num},${DGC_sample_num}

## RNA
use_sample=`cat ${mRNA_path}/NJSCC.DNAUse.53_157.tsv | head -1 | tr '\t' '\n' | grep -v gene | awk -F'_' '{print $1}' | 
sort -u  | tr '\n' '|' | sed 's/|$//'`
IM_sample_num=`cat ${config_path}/tumor_normal.class.MSS_MSI.list | grep -E -w ${use_sample} | grep IM- | wc -l`
IGC_sample_num=`cat ${config_path}/tumor_normal.class.MSS_MSI.list | grep -E -w ${use_sample} | grep IGC- | wc -l`
DGC_sample_num=`cat ${config_path}/tumor_normal.class.MSS_MSI.list | grep -E -w ${use_sample} | grep DGC- | wc -l`
Normal_sample_num=`cat ${mRNA_path}/NJSCC.DNAUse.53_157.tsv | head -1 | tr '\t' '\n' | grep Normal | wc -l`

echo "Normal_sample_num,IM_sample_num,IGC_sample_num,DGC_sample_num"
echo ${Normal_sample_num},${IM_sample_num},${IGC_sample_num},${DGC_sample_num}


##########################################
## GS亚型定义
## 用于分子分型
## NMU所有样本，包含了MSI的样本
sh ${scripts_path}/gistic2/gistic2.CIN.sh
## 判断CNV的亚型
${Rscript} ${scripts_path}/gistic2/classify_CIN.R \
--sample_file ${config_path}/tumor_normal.class.list \
--burden_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.tsv \
--gistic_file ${work_dir}/gistic/all_lesions.conf_99.txt \
--out_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv

## CNV的染色体分布
## NJMU和TCGA的IGC、DGC的两种CNV亚型改变
${Rscript} ${scripts_path}/plot/cnvDistribution_plot.combine.R \
--sample_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--seg_file ${Titan_path}/Titan_all_seg.final.tsv \
--sample_public_file ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv \
--seg_public_file ${work_dir}/seg_public/TCGA_use.seg \
--class_order_file ${config_path}/Class_order.list \
--images_path ${work_dir}/finalPlot/molecular_type/cnv_burden


##########################################
## 突变负荷比较
## IGC和DGC的突变负荷在MSS中比较，对应的Figure2的a图
## MutationBurden.combine.IGC_DGC.MSS.pdf
## MutationBurden.combine.IGC_DGC.MSS.tsv
## 不同来源的比较，对应的Supplyment Fig1
## MutationBurden.compare.IGC_DGC.MSS.pdf
${Rscript} ${scripts_path}/comparePublicData/CombinePublicData.R \
--njmu_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.tsv \
--tcga_file ${work_dir}/public_ref/TCGA/TCGA_STAD.TMB.tsv \
--tcga_clinic_file ${work_dir}/public_ref/TCGA/clinical_PANCAN_patient_with_followup.tsv \
--tcga_msi_file  ${work_dir}/public_ref/TCGA/TCGA_STAD_msi.TMB.tsv \
--oncoSG_file ${work_dir}/public_ref/OncoSG/OncoSG_STAD.TMB.tsv \
--oncoSG_clinic_file ${work_dir}/public_ref/OncoSG/OncoSG_STAD.followup.tsv \
--oncoSG_msi_file ${work_dir}/public_ref/OncoSG/OncoSG_STAD_msi.TMB.tsv \
--tmucih_file ${work_dir}/public_ref/TMUCIH/TMUCIH_STAD.TMB.tsv \
--tmucih_msi_file ${work_dir}/public_ref/TMUCIH/TMUCIH_STAD_msi.TMB.tsv \
--utokyo_file ${work_dir}/public_ref/utokyo/utokyo_STAD.TMB.tsv \
--out_path ${work_dir}/finalPlot/molecular_type/mutBurden


##########################################
## IGC和DGC的突变负荷在不同分子亚型中比较，对应的Figure2的b图
## MutationBurden.compare.IGC_DGC.MolecularType.All.pdf
## 不同来源的比较，对应的Supplyment Fig2
## MutationBurden.compare.IGC_DGC.MolecularType.NJMU.pdf
## MutationBurden.compare.IGC_DGC.MolecularType.OncoSG.pdf
## MutationBurden.compare.IGC_DGC.MolecularType.TCGA.pdf
${Rscript} ${scripts_path}/plot/mutBurden.MolecularType.R \
--input_file ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv \
--out_path ${work_dir}/finalPlot/molecular_type/mutBurden


##########################################
## 森林图比较吸烟、饮酒和HP对突变负荷的影响，对应的Supplyment Fig3
molecular_type_list=("All" "GS" "CIN")
for molecular_type in ${molecular_type_list[@]}
do
${Rscript} ${scripts_path}/finalPlot/DescribeMutBurden.logistic.R \
--info_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--molecular_type ${molecular_type} \
--images_path ${work_dir}/finalPlot/molecular_type/logistic

## logistic回归,森林图可视化
${Rscript} ${scripts_path}/finalPlot/DescribeMutBurdenRatio.logistic.plot.R \
--input_burden_file ${work_dir}/finalPlot/molecular_type/logistic/baseInfo_mutBurden.${molecular_type}.tsv \
--molecular_type ${molecular_type} \
--out_path ${work_dir}/finalPlot/molecular_type/logistic
done


##########################################
## 同一个人配对IM、IGC和DGC的突变负荷的比较，只画MSS患者且不包含5例IGC和DGC均有的样本，对应的Figure3的a图
## mutBurden.Type.IM_IGC-IM_DGC.MSS.pdf
${Rscript} ${scripts_path}/mutBurden/mutBurden_plot.addMSI.R \
--info_file ${config_path}/STAD-useCombine.Sample.tsv \
--maf_file ${maf_path}/All_ForMutBurden.extract.maf \
--maf_msi_file ${maf_path}/All_ForMutBurden.extract.MSI.maf \
--images_path ${work_dir}/finalPlot/molecular_type/mutBurden

##########################################
## MSI、GS、CIN的IM的突变负荷比较mutBurden.IM.TCGA_Type.GS_CIN_MSI.All.All.pdf，对应的Figure3的c图
${Rscript} ${scripts_path}/mutBurden/mutBurden_plot.IM_MolecularType.R \
--info_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--images_path ${work_dir}/finalPlot/molecular_type/mutBurden 

## 突变负荷与性别、吸烟、饮酒、HP的关系
${Rscript} ${scripts_path}/mutBurden/mutBurden_plot.Baseline.R \
--input_file ${baseTable_path}/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--images_path ${work_dir}/finalPlot/molecular_type/mutBurden/baseline

##########################################
## MSI、GS、CIN的IM的共享和私有功能性突变的CCF分析
${Rscript} ${scripts_path}/plot/mutBurden.MolecularType.ShareRate.R \
--mutshare_file ${Images_path}/mutRate/MutShare.AllPoint.tsv \
--mutshare_msi_file ${Images_path}/mutRateMSI/MutShare.AllPoint.tsv \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.tsv \
--ccf_msi_file ${MutationTime_path}/result/All_CCF_mutTime.MSI.tsv \
--input_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--images_path ${work_dir}/finalPlot/molecular_type/mutBurden/baseline

########################################## 
## 突变信号
sh ${scripts_path}/module/sigprofile_AllVcf.AllMut.sh

${Rscript} ${scripts_path}/sigprofile/Sigprofiler_decompose_plot_v2.GetRatio.AllMut.R \
--sig_msi_file ${SigProfiler_path}/decompose_allUSE_AllMut_MSI/combine_SBS96.txt \
--sig_mss_file ${SigProfiler_path}/decompose_allUSE_AllMut_MSS/combine_SBS96.txt \
--info_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--info_public_file ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv \
--images_path ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut

## NJMU中看share、trunk和private
## 不同的分子亚型
mol_type_list=("MSS" "MSI" "CIN" "GS")
for mol_type in ${mol_type_list[@]}
do
${Rscript} ${scripts_path}/sigprofile/Sigprofiler_decompose_plot_v2.AllVcf.Share.R \
--input_file ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut/combine_SBS96.ratio.addInfo.tsv \
--mol_type ${mol_type} \
--images_path ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut

## IGC和DGC的合并
## 总的以及不同来源的展示
${Rscript} ${scripts_path}/sigprofile/Sigprofiler_decompose_plot_v2.AllVcf.From.R \
--input_file ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut/combine_SBS96.ratio.addInfo.tsv \
--mol_type ${mol_type} \
--images_path ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut
done

## 每个人的突变信号组成
${Rscript} ${scripts_path}/sigprofile/Sigprofiler_decompose_plot_v2.AllVcf.EverySample.R \
--input_file ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut/combine_SBS96.ratio.addInfo.tsv \
--images_path ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut

##########################################
## CNV的染色体分布
## NJMU和TCGA的IGC、DGC的两种CNV亚型改变
${Rscript} ${scripts_path}/plot/cnvDistribution_plot.combine.R \
--sample_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--seg_file ${Titan_path}/Titan_all_seg.final.tsv \
--sample_public_file ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv \
--seg_public_file ${work_dir}/seg_public/TCGA_use.seg \
--class_order_file ${config_path}/Class_order.list \
--images_path ${work_dir}/finalPlot/molecular_type/cnv_burden

## 拷贝数的比较
## 排除MSI的患者
## CNV的负荷
from_type=("All" "NJMU" "TCGA")
for from in ${from_type[@]}
do
${Rscript} ${scripts_path}/plot/cnvBurden_plot.combine.R \
--from ${from} \
--sample_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--seg_file ${Titan_path}/Titan_all_seg.final.tsv \
--sample_public_file ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv \
--seg_public_file ${work_dir}/seg_public/TCGA_use.seg \
--class_order_file ${config_path}/Class_order.list \
--images_path ${work_dir}/finalPlot/molecular_type/cnv_burden
done

## NJMU的不同类型的肠化样本比较
${Rscript} ${scripts_path}/plot/cnvBurden_plot.IM.R \
--sample_file ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--seg_file ${Titan_path}/Titan_all_seg.final.tsv \
--class_order_file ${config_path}/Class_order.list \
--images_path ${work_dir}/finalPlot/molecular_type/cnv_burden


####################################################################################
## 模式图
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/MutationBurden.compare.IGC_DGC.MolecularType.All.mode.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IGC_DGC.MolecularType.mode.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/baseline/mutBurden.Alcohol.cds.IM.MolType.mode.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IM.TCGA_Type.Alcohol.mode.pdf
ln -snf ${work_dir}/finalPlot/SMG_Waterfull/Mut_WaterFall.new.mode.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.waterfull_smg.mode.pdf

## 不同分子亚型的CNV在NJMU和TCGA的比较
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CopyRatioDis.DGC.NJMU.pdf ${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.cnv_njmu.DGC.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CopyRatioDis.IGC.NJMU.pdf ${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.cnv_njmu.IGC.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CopyRatioDis.DGC.TCGA.pdf ${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.cnv_tcga.DGC.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CopyRatioDis.IGC.TCGA.pdf ${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.cnv_tcga.IGC.pdf

## MSS稳定的IGC和DGC的突变负荷
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/MutationBurden.combine.IGC_DGC.MSS.pdf ${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IGC_DGC.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/MutationBurden.combine.IGC_DGC.MSS.tsv ${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IGC_DGC.tsv
## 不同来源
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/MutationBurden.compare.IGC_DGC.MSS.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.IGC_DGC.From.pdf

## 不同分子亚型的突变负荷
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/MutationBurden.compare.IGC_DGC.MolecularType.All.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IGC_DGC.MolecularType.All.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/MutationBurden.compare.IGC_DGC.MolecularType.All.tsv \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IGC_DGC.MolecularType.All.tsv
## 不同来源
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/MutationBurden.compare.IGC_DGC.MolecularType.NJMU.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.IGC_DGC.MolecularType.NJMU.pdf
## 不同来源
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/MutationBurden.compare.IGC_DGC.MolecularType.OncoSG.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.IGC_DGC.MolecularType.OncoSG.pdf
## 不同来源
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/MutationBurden.compare.IGC_DGC.MolecularType.TCGA.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.IGC_DGC.MolecularType.TCGA.pdf

## 森林图展示基线对突变负荷的影响
ln -snf ${work_dir}/finalPlot/molecular_type/logistic/baseInfo_coef.All.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.baseInfo_coef.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/logistic/baseInfo_coef.All.tsv \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.baseInfo_coef.tsv
## 不同分子亚型
ln -snf ${work_dir}/finalPlot/molecular_type/logistic/baseInfo_coef.GS.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.baseInfo_coef.GS.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/logistic/baseInfo_coef.GS.tsv \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.baseInfo_coef.GS.tsv
ln -snf ${work_dir}/finalPlot/molecular_type/logistic/baseInfo_coef.CIN.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.baseInfo_coef.CIN.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/logistic/baseInfo_coef.CIN.tsv \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.baseInfo_coef.CIN.tsv

## 同一患者配对IM的TMB
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/mutBurden.Type.IM_IGC-IM_DGC.MSS.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IM_IGC-IM_DGC.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/mutBurden.Type.IM_IGC-IM_DGC.MSS.tsv \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IM_IGC-IM_DGC.tsv
## 不同IM的比较
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/mutBurden.Type.IM.MSS.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.IM_Compare.pdf

## 不同分子亚型IM的TMB
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/mutBurden.IM.TCGA_Type.GS_CIN_MSI.All.All.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IM.TCGA_Type.GS_CIN_MSI.All.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/mutBurden.IM.TCGA_Type.GS_CIN_MSI.All.All.tsv \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IM.TCGA_Type.GS_CIN_MSI.All.tsv
## 不同胃癌亚型中不同分子亚型IM的比较
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/mutBurden.IM.TCGA_Type.GS_CIN_MSI.All.IGC_DGC.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.IM.TCGA_Type.GS_CIN_MSI.IGC_DGC.pdf

## IM突变负荷与饮酒关系
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/baseline/mutBurden.Alcohol.cds.IM.MolType.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IM.TCGA_Type.Alcohol.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/baseline/mutBurden.Alcohol.cds.IM.MolType.tsv \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IM.TCGA_Type.Alcohol.tsv

## 不同分子亚型IM，其共享突变的CCF占比
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/baseline/mutBurden.IM.TCGA_Type.GS_CIN_MSI.MutCCFRate.Share.All_Drink.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IM.TCGA_Type.MutCCFRate.Share.Alcohol.All_Drink.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/baseline/mutBurden.IM.TCGA_Type.GS_CIN_MSI.MutCCFRate.Share.Drink.tsv \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.IM.TCGA_Type.MutCCFRate.Share.Alcohol.Share.Drink.tsv
## 附图
ln -snf ${work_dir}/finalPlot/molecular_type/mutBurden/baseline/mutBurden.IM.TCGA_Type.GS_CIN_MSI.MutCCFRate.Share.Non-Drink.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.IM.TCGA_Type.MutCCFRate.Share.Alcohol.Non-Drink.pdf


## 突变信号构成
ln -snf ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut/SBS_96_plots_SBS96_De-Novo.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.SBS_96_plots_SBS96_De-Novo.pdf
## 总体的突变信号，不同来源
ln -snf ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut/Mutation_Signature.decompose.Combine.MSS.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.Mutation_Signature.decompose.Combine.MSS.pdf
## NJMU中共享和私有的突变信号
ln -snf ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut/Mutation_Signature.decompose.NJMU.MSS.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.Mutation_Signature.decompose.NJMU.MSS.pdf
## 不同分子亚型的
ln -snf ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut/Mutation_Signature.decompose.Combine.GS.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.Mutation_Signature.decompose.GS.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut/Mutation_Signature.decompose.Combine.CIN.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.Mutation_Signature.decompose.CIN.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/decompose_allUSE_AllMut/Mutation_Signature.decompose.Combine.MSI.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.Mutation_Signature.decompose.MSI.pdf

## 拷贝数分布图
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CopyRatioDis.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.CopyRatioDis.pdf
## 拷贝数改变负荷
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CNV_burden.IGC_DGC.All.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.CNV_burden.IGC_DGC.All.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CNV_Burden_ALL.All.tsv \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.CNV_burden.IGC_DGC.All.tsv

## 不同亚型
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CNV_burden.IGC_DGC.CIN.All.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.CNV_burden.IGC_DGC.CIN.All.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CNV_Burden_ALL.All.Molecular.subtype.tsv \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.CNV_burden.IGC_DGC.CIN.All.tsv

ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CNV_burden.IGC_DGC.GS.All.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.CNV_burden.IGC_DGC.GS.All.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CNV_burden.IGC_DGC.CIN.All.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.CNV_burden.IGC_DGC.CIN.All.pdf
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CNV_burden.IGC_DGC.MSI.All.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Supplementary_Fig.CNV_burden.IGC_DGC.MSI.All.pdf

## IM的拷贝数比较
ln -snf ${work_dir}/finalPlot/molecular_type/cnv_burden/CNV_burden.IM_GC.All.pdf \
${work_dir}/finalPlot/Plot_Article/Part1/Figure1.CNV_burden.IM.pdf

####################################################################################
## 第二部分
## 显著突变基因
####################################################################################

mkdir -p ${work_dir}/finalPlot/SMG_Waterfull/

cp ${mutsig_check_path}/smg.list ${mutsig_check_path}/smg.addEvolution.list 
echo -e "MICAL2\nDNAH3" >> ${mutsig_check_path}/smg.addEvolution.list 

cp ${mutsig_check_path}/igc_smg.list ${mutsig_check_path}/igc_smg.addEvolution.list 
echo -e "MICAL2\nDNAH3" >> ${mutsig_check_path}/igc_smg.addEvolution.list 

cp ${mutsig_check_path}/dgc_smg.list ${mutsig_check_path}/dgc_smg.addEvolution.list 
echo -e "MICAL2" >> ${mutsig_check_path}/dgc_smg.addEvolution.list 

echo "Gene_Symbol" > ${mutsig_check_path}/All_driver.list
cat ${mutsig_check_path}/dgc_smg.addEvolution.list ${mutsig_check_path}/igc_smg.addEvolution.list ${mutsig_check_path}/im_smg.list | grep -v Gene | sort -u \
>> ${mutsig_check_path}/All_driver.list

##########################################
## 多少IM、IGC、DGC携带突变
driverGene=`cat ${mutsig_check_path}/smg.list | grep -v Gene_Symbol  | tr '\n' '|' | sed 's/|$//'`
Variant_Type="Missense_Mutation|Nonsense_Mutation|Frame_Shift_Ins|Frame_Shift_Del|In_Frame_Ins|In_Frame_Del|Splice_Site|Nonstop_Mutation"

igc_sample=`cat ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv | grep -v MSI | grep IGC | grep -v DGC | \
awk -F'\t' '{print $1}' | tr '\n' '|' | sed 's/|$//'`
dgc_sample=`cat ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv | grep -v MSI | grep DGC | grep -v IGC | \
awk -F'\t' '{print $1}' | tr '\n' '|' | sed 's/|$//'`
im_sample=`cat ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv | grep -v MSI | grep NJMU | grep -v "IGC + DGC" | \
awk -F'\t' '{print $1}' | tr '\n' '|' | sed 's/|$//'`

igc_sample_num=`cat ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv | grep -v MSI | grep IGC | grep -v DGC | wc -l`
dgc_sample_num=`cat ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv | grep -v MSI | grep DGC | grep -v IGC | wc -l`
im_sample_num=`cat ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv | grep -v MSI | grep NJMU | grep -v "IGC + DGC" | wc -l`

igc_mut_num=`cat ${work_dir}/maf_public/All_use.maf | grep -E -w ${driverGene} | grep -E -w ${Variant_Type} | grep -E -w ${igc_sample} | \
awk -F'\t' '{print $3}' | sort -u | wc -l`
dgc_mut_num=`cat ${work_dir}/maf_public/All_use.maf | grep -E -w ${driverGene} | grep -E -w ${Variant_Type} | grep -E -w ${dgc_sample} | \
awk -F'\t' '{print $3}' | sort -u | wc -l`
im_mut_num=`cat ${work_dir}/maf_public/All_use.IM.maf | grep -E -w ${driverGene} | grep -E -w ${Variant_Type} | grep -E -w ${im_sample} | \
awk -F'\t' '{print $3}' | sort -u | wc -l`

echo -e "igc_sample_num\tigc_mut_num"
echo -e $igc_sample_num"\t" ${igc_mut_num}

echo -e "dgc_sample_num\tdgc_mut_num"
echo -e $dgc_sample_num"\t" ${dgc_mut_num}

echo -e "im_sample_num\tim_mut_num"
echo -e $im_sample_num"\t" ${im_mut_num}

##########################################
## 突变瀑布图
${Rscript} ${scripts_path}/plot/waterfull_smg.new_v2.R \
--maf_path ${maf_public_path} \
--images_path ${work_dir}/finalPlot/SMG_Waterfull/ \
--info_file ${config_path}/tumor_normal.class.list \
--info_public_file ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv \
--class_order_file ${config_path}/Class_order.list \
--im_list ${mutsig_check_path}/im_smg.list \
--igc_list ${mutsig_check_path}/igc_smg.list \
--dgc_list ${mutsig_check_path}/dgc_smg.list

##########################################
## 突变率的比较
from=All
${Rscript} ${scripts_path}/plot/mutRate_plot.All.R \
--smg_file ${mutsig_check_path}/smg.list \
--mut_rate_gene_file ${Images_path}/mutRate/MutRate.tsv \
--from ${from} \
--images_path ${work_dir}/finalPlot/SMG_Waterfull/

## 驱动基因突变率在不同亚型
mol_type_list=("MSI" "CIN" "GS")
for mol_type in ${mol_type_list[@]}
do
${Rscript} ${scripts_path}/plot/mutRate_plot.MolType.R \
--smg_file ${mutsig_check_path}/smg.list \
--mut_rate_gene_file ${Images_path}/mutRate/MutRate.molType.tsv \
--mol_type ${mol_type} \
--images_path ${work_dir}/finalPlot/SMG_Waterfull/
done


##########################################
## 共出现和互斥
class_type_list=("IGC" "DGC")
for class_type in ${class_type_list[@]}
do
## 计算
${Rscript} ${scripts_path}/plot/DriverGene.Exclusive.R \
--maf_path ${maf_public_path} \
--class_type ${class_type} \
--images_path ${work_dir}/finalPlot/SMG_Waterfull/ \
--info_file ${config_path}/tumor_normal.class.list \
--info_public_file ${work_dir}/public_ref/combine/MutationInfo.combine.addMolecularSubType.tsv \
--class_order_file ${config_path}/Class_order.list \
--im_list ${mutsig_check_path}/im_smg.list \
--igc_list ${mutsig_check_path}/igc_smg.list \
--dgc_list ${mutsig_check_path}/dgc_smg.list
## 画图
${Rscript} ${scripts_path}/plot/heatMap.con_exclusive.R \
--class_type ${class_type} \
--input_file ${work_dir}/finalPlot/SMG_Waterfull/MutuallyExclusive.${class_type}.tsv  \
--images_path ${work_dir}/finalPlot/SMG_Waterfull/
done


####################################################################################
## 第三部分克隆演化
####################################################################################

mkdir -p ${work_dir}/finalPlot/SMG_Evolution/

##########################################

for gene in `cat ${mutsig_check_path}/smg.list | grep -v Gene_Symbol | sort -u`
do
#### 突变棒棒糖图
## NMU的样本中
## 比较配对IM及其IGC/DGC的突变分别是否存在差异
${Rscript} ${scripts_path}/plot/Lollipop_variant.R \
--gene ${gene} \
--pre_file ${maf_path}/All_GGA.precancer.maf \
--cancer_file ${maf_path}/All_GGA.cancer.maf \
--sample_info ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--gtf_file ${ref_path}/GTF/gencode.v19.annotation.exonNum.gtf \
--out_path ${Images_path}/lollipop/${gene}_NMU
done

##########################################
## 比较不同人种突变率的差异
${Rscript} ${scripts_path}/plot/mutRate_plot.race.R \
--smg_file ${mutsig_check_path}/smg.list \
--mut_rate_gene_file ${Images_path}/mutRate/MutRate.race.tsv \
--images_path ${work_dir}/finalPlot/SMG_Evolution/race

##########################################
## 计算每个基因的Driver的CCF
echo "Gene_Symbol" > ${mutsig_check_path}/show_gene.list
cat ${Images_path}/selectGCClone/GCClone_gene.all_record.list ${mutsig_check_path}/smg.list | grep -v Gene | sort -u >> ${mutsig_check_path}/show_gene.list

${Rscript} ${scripts_path}/tree/GetDriverEverySample.R \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--gene_list ${mutsig_check_path}/show_gene.list  \
--sample_info ${config_path}/tumor_normal.class.MSS_MSI.list \
--out_path ${Images_path}/DriverEverySample \
--class_order_file ${config_path}/Class_order_sub.list 

##########################################
## 基因是共享、IM私有还是胃癌私有
## IGC和DGC的样本分开来看
clone_t=0.6
choose_rate=0
class_type_list=("IGC" "DGC")
for class_type in ${class_type_list[@]}
do
## 驱动基因的共享和私有情况
${Rscript} ${scripts_path}/plot/JudgeGeneDriverSharePrivate.R \
--muti_cancer ${maf_path}/All_GGA.cancer.maf \
--muti_pre ${maf_path}/All_GGA.precancer.maf \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.tsv \
--gene_list ${mutsig_check_path}/smg.list  \
--sample_info ${config_path}/tumor_normal.class.list \
--type ${class_type} \
--clone_t ${clone_t} \
--choose_rate ${choose_rate} \
--out_path ${work_dir}/finalPlot/SMG_Evolution/share_private
done

##########################################
## 描述驱动胃癌发生的四个基因，其克隆选择情况
${Rscript} ${scripts_path}/finalPlot/waterfull_smg.SortBySample.v1.R \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--images_path ${work_dir}/finalPlot/SMG_Evolution/ \
--info_file ${config_path}/tumor_normal.class.list \
--class_order_file ${config_path}/Class_order.list \
--smg_list ${Images_path}/selectGCClone/GCClone_gene.all_record.list  \
--class_order_sub_file ${config_path}/Class_order_sub.list \
--tp53_pre_file ${Images_path}/lollipop/TP53_NMU/TP53.PreCancerous.UniqueNormal.tsv \
--tp53_cancer_file ${Images_path}/lollipop/TP53_NMU/TP53.Cancerous.UniqueNormal.tsv 


##########################################
## TP53、APC、PIK3CA和CDH1的share突变和Private的LOH
## IGC和DGC分开来
## 未看见差异
<<EOF
class_type_list=("All" "IGC" "DGC" )
for class_type in ${class_type_list[@]}
do
## 判断IM和GC共享以及GC中发生在早期的克隆突变其LOH相比于其它突变的情况
${Rscript} ${scripts_path}/finalPlot/JudgeGeneDriverLOH.R \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--gene_list ${Images_path}/selectGCClone/GCClone_gene.all_record.list  \
--sample_info ${config_path}/tumor_normal.class.list \
--type ${class_type} \
--out_path ${work_dir}/finalPlot/SMG_Evolution/LOH
done
## TP53的LOH
## 总的、IGC和DGC的
${Rscript} ${scripts_path}/finalPlot/JudgeGeneDriverLOH.TP53.R \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--gene_list ${Images_path}/selectGCClone/GCClone_gene.all_record.list  \
--sample_info ${config_path}/tumor_normal.class.list \
--out_path ${work_dir}/finalPlot/SMG_Evolution/LOH
EOF

## APC的最小拷贝数丢失
## 总的、IGC和DGC的
${Rscript} ${scripts_path}/finalPlot/JudgeGeneDriverLOH.Gene.R \
--geneN APC \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--gene_list ${Images_path}/selectGCClone/GCClone_gene.all_record.list  \
--sample_info ${config_path}/tumor_normal.class.list \
--out_path ${work_dir}/finalPlot/SMG_Evolution/LOH

##########################################
## TP53、APC、PIK3CA和CDH1的share突变、私有突变以及野生型的表达
## CDH1可以讲
gene_list=("RNF43" "TP53" "CDH1" "APC" "PIK3CA")
for gene in ${gene_list[@]}
do
${Rscript} ${scripts_path}/mRNA/showGene.Normalize.TrunkvsPrivate.R \
--sample_list_file ${config_path}/tumor_normal.class.list \
--mut_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--rsem_file ${mRNA_path}/CombineTMM.DNAUse.NJMU_TCGA.tsv \
--out_path ${work_dir}/finalPlot/SMG_Evolution/expression \
--gene ${gene}
done

##########################################
## CDH1可变剪接可视化
mkdir -p ${work_dir}/finalPlot/SMG_Evolution/cdh1

cat ~/20220915_gastric_multiple/rna_combine/analysis/config/tumor_normal.list  | awk -F'\t' '{OFS="\t"}{print $0,$1"_"$5}' \
> ${work_dir}/finalPlot/SMG_Evolution/cdh1/Tumor_Normal_RNA.tsv

## 1、提取CDH1的bam文件
for sample in `cat ${config_path}/tumor_normal.class.list  | grep DGC- | grep -v IGC | awk -F'\t' '{print $1"_"$5}'`
do
rna_id=`cat ${work_dir}/finalPlot/SMG_Evolution/cdh1/Tumor_Normal_RNA.tsv | grep ${sample} | awk -F'\t' '{print $3}'`
rna_id_exist=`cat ${work_dir}/finalPlot/SMG_Evolution/cdh1/Tumor_Normal_RNA.tsv | grep ${sample} | awk -F'\t' '{print $3}' | wc -l`

if [ ${rna_id_exist} -gt 0 ]
then
samtools view -hb ~/20220915_gastric_multiple/rna_combine/STAR/${rna_id}.Aligned.sortedByCoord.out.bam 16:68771128-68867487 \
> ${work_dir}/finalPlot/SMG_Evolution/cdh1/${sample}.cdh1.bam
samtools index ${work_dir}/finalPlot/SMG_Evolution/cdh1/${sample}.cdh1.bam
fi
done

#16:68836036-68856036

##########################################
## CDH1和SMAD4一起出现几次在DGC中
Variant_Types="Missense_Mutation|Nonsense_Mutation|Frame_Shift_Ins|Frame_Shift_Del|In_Frame_Ins|In_Frame_Del|Splice_Site|Nonstop_Mutation"

echo -e sample"\t"mut_num > ${work_dir}/finalPlot/SMG_Evolution/cdh1/record_SMAD4_CDH1_con.tsv
for sample in `cat ${config_path}/tumor_normal.class.list | sed '1d' | awk -F'\t' '{print $3}' | sort -u`
do
line=`cat ${MutationTime_path}/result/All_CCF_mutTime.tsv | grep -w -E "CDH1|SMAD4" | grep -w ${sample} | grep -E -w ${Variant_Types} | wc -l`
echo -e ${sample}"\t"${line} >> ${work_dir}/finalPlot/SMG_Evolution/cdh1/record_SMAD4_CDH1_con.tsv
done

##########################################
## 每个基因，其所在的所有进化树，所有基因的CCF改变，所在样本的克隆演化树

Variant_Types="Missense_Mutation|Nonsense_Mutation|Frame_Shift_Ins|Frame_Shift_Del|In_Frame_Ins|In_Frame_Del|Splice_Site|Nonstop_Mutation"

gene=TP53
## IGC和PIK3CA共存
Normal=JZGCWES731
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf
## DGC和RHOA共存
Normal=JZGCWES0908
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf


## IGC和DGC均有的样本
Normal=JZGCWES0693
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf

gene=APC
Normal=S63
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf
Normal=JZGCWES0941
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf

gene=PIK3CA
Normal=JZ464B
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf
Normal=JZGCWES1033
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf

gene=CDH1
Normal=JZ618B
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf

Normal=JZGCWES0698
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf


gene=SMAD4
Normal=JZ585B
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf

## RHOA也是
Normal=JZGCWES0908
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf

gene=MTRR
Normal=JZGCWES1100
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf

Normal=JZGCWES1065
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf

gene=RNF43
Normal=JZ549B
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf
Normal=JZ664B
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf
Normal=JZGCWES1009N
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf

gene=ARID1A
Normal=JZGCWES1011
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf

gene=ERBB2
Normal_list=(JR8 JZ539B JZ645B)
for Normal in ${Normal_list[@]}
do
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/SMG_Evolution/${gene}.${Normal}_Driver.pdf
done



####################################################################################
## 第四部分MUC6
####################################################################################
##########################################
mkdir -p ${work_dir}/finalPlot/MUC6_BMP6_CFTR 

## MUC6的recurrent突变总的占比、其突变的share和private以及克隆和亚克隆
${Rscript} ${scripts_path}/finalPlot/MUC6.recurretn.R \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--sample_info ${config_path}/tumor_normal.class.list \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR \
--gene_list_file ${Images_path}/selectGCClone/GCClone_gene.all_record.report.list

##########################################
## MUC6突变患者不同细胞的比例构成
gene=MUC6
${Rscript_singlecell} ${scripts_path}/singlecell/compare_CellRatio.R \
--sample_list_file ${config_path}/tumor_normal.class.MSS_MSI.list \
--singleCell_sample_file ${config_path}/singleCell_Sample.useThree.list \
--maf_file ${maf_path}/All_GGA.all.maf \
--maf_msi_file ${maf_path}/All_GGA.all.MSI.maf \
--single_cell_file ${work_dir}/public_ref/singleCell/njmu/epiall_nor_PCA_50_RE0.5.Rdata \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR/singleCellRatio \
--gene ${gene}

##########################################
## 在有MUC6突变的样本中，计算MUC6突变与哪个细胞相关
${Rscript_singlecell} ${scripts_path}/singlecell/scissor_cell_OurData.MUC6.R \
--sample_list_file ${config_path}/tumor_normal.class.list \
--sample_list_public_file ${work_dir}/public_ref/combine/MutationInfo.combine.tsv \
--rsem_file ${mRNA_path}/CombineTPM.DNAUse.NJMU_TCGA.tsv \
--maf_public_file ${work_dir}/maf_public/All_use.addVAF.maf \
--single_cell_file ${work_dir}/public_ref/singleCell/njmu/epiall_nor_PCA_50_RE0.5.Rdata \
--out_path  ${work_dir}/finalPlot/MUC6_BMP6_CFTR/scissor \
--mut_type all \
--gene MUC6

## 画图
${Rscript_singlecell} ${scripts_path}/singlecell/scissor_cell_OurData.Counts.R \
--input_im_file ${work_dir}/finalPlot/MUC6_BMP6_CFTR/scissor/Scissor_STAD_MUC6_mutation.IM.CellRate.all.tsv \
--single_cell_file  ${work_dir}/finalPlot/MUC6_BMP6_CFTR/scissor/Scissor_STAD_MUC6_mutation.IM.CellRate.all.RData \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR/scissor \
--type all \
--gene MUC6

##########################################
## 细胞互作
${Rscript_cpbd} ${scripts_path}/singlecell/cellphonedb.R \
--single_cell_file ${Images_path}/singleCell_MUC6/Scissor_STAD_MUC6_mutation.IM.CellRate.all.RData \
--out_path ${Images_path}/singleCell_MUC6/cpdb
## 运行cellphonedb
${python_cpbd} ${scripts_path}/singlecell/cellphonedb.py
## 可视化
${Rscript_cpbd} ${scripts_path}/singlecell/ktplots.R \
--pvals_file ${Images_path}/singleCell_MUC6/cpdb/statistical_analysis_pvalues_IM_MUC6.txt \
--means_file ${Images_path}/singleCell_MUC6/cpdb/statistical_analysis_means_IM_MUC6.txt \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR/cpdb

## 检查观察到的受体配体互作的基因的表达分布
## LGR5是胃干细胞的marker，检查是否这簇Pit和胃干细胞相似
gene_list=( DSC2 DSG2 )
for gene in ${gene_list[@]}
do
${Rscript_singlecell} ${scripts_path}/singlecell/showGene.vln.MUC6.R \
--single_cell_file ${Images_path}/singleCell_MUC6/Scissor_STAD_MUC6_mutation.IM.CellRate.all.RData \
--gene ${gene} \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR/cpdb
done

##########################################
## 突变型Pit和野生型Pit的差异表达
${Rscript_singlecell} ${scripts_path}/singlecell/differexpression.MUC6.R \
--single_cell_file ${work_dir}/finalPlot/MUC6_BMP6_CFTR/scissor/Scissor_STAD_MUC6_mutation.IM.CellRate.all.RData \
--gene MUC6 \
--cds_file ~/ref/PCAWG_Elements/web_hg19/gc19_pc.cds.use.bed \
--pathway_path ~/ref/Pathway/ \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR/Diff

## 差异表达仅画图
${Rscript_singlecell} ${scripts_path}/singlecell/differexpression.MUC6.plot.R \
--input_file ${work_dir}/finalPlot/MUC6_BMP6_CFTR/Diff/DiffGene.Pit.tsv \
--gene MUC6 \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR/Diff

## GKN1_GKN2均高表达的细胞在MUC6突变相关Pit是否存在差异
## 合并其它细胞为一类
${Rscript_singlecell} ${scripts_path}/singlecell/compare_PitCellRatio.GKN1_GKN2.R \
--sample_list_file ${config_path}/tumor_normal.class.MSS_MSI.list \
--singleCell_sample_file ${config_path}/singleCell_Sample.useThree.list \
--single_cell_scissor_file ${Images_path}/singleCell_MUC6/Scissor_STAD_MUC6_mutation.IM.CellRate.all.RData \
--single_cell_file ${work_dir}/public_ref/singleCell/njmu/epiall_nor_PCA_50_RE0.5.Rdata \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR/Diff \
--gene "GKN1_GKN2"

## MUC6突变和野生型样本，GKN1和GKN2的表达
${Rscript} ${scripts_path}/mRNA/showGene.Normalize.MutvsWild.MUC6.GKN1_GKN2.R \
--sample_list_file ${config_path}/tumor_normal.class.list \
--sample_list_public_file ${work_dir}/public_ref/combine/MutationInfo.combine.tsv \
--rsem_file ${mRNA_path}/CombineTMM.DNAUse.NJMU_TCGA.tsv \
--maf_public_file ${work_dir}/maf_public/All_use.addVAF.maf \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR/Diff \
--gene MUC6


## 展示MUC6和GKN1/GKN2的表达分布
## 附件
${Rscript_singlecell} ${scripts_path}/singlecell/showGene.vln.MUC6.R \
--single_cell_file ${work_dir}/finalPlot/MUC6_BMP6_CFTR/scissor/Scissor_STAD_MUC6_mutation.IM.CellRate.all.RData \
--gene MUC6 \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR/Diff

<<EOF
## 看不到啥意义
## 比较MUC6突变和野生型整体在IM的差异表达情况
${Rscript} ${scripts_path}/mRNA/showGene.Normalize.MutvsWild.MUC6.AllGene.R \
--sample_list_file ${config_path}/tumor_normal.class.list \
--sample_list_public_file ${work_dir}/public_ref/combine/MutationInfo.combine.tsv \
--rsem_file ${mRNA_path}/CombineTMM.DNAUse.NJMU_TCGA.tsv \
--maf_public_file ${work_dir}/maf_public/All_use.addVAF.maf \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR/Diff \
--gene MUC6
EOF

##########################################
## CFTR和BMP6的棒棒糖图以及共享和私有
gene_list=(BMP6 CFTR MTRR)
for gene in ${gene_list[@]}
do
${Rscript} ${scripts_path}/finalPlot/BMP6_CFTR.recurrent.R \
--gene ${gene} \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--sample_info ${config_path}/tumor_normal.class.list \
--out_path ${work_dir}/finalPlot/MUC6_BMP6_CFTR \
--gene_list_file ${Images_path}/selectGCClone/GCClone_gene.all_record.report.list
done


####################################################################################
## 第5部分进化模式
####################################################################################
mkdir -p ${work_dir}/finalPlot/Evolution_Driver

##########################################
## 描述驱动胃癌发生的四个基因，其克隆选择情况
${Rscript} ${scripts_path}/finalPlot/waterfull_smg.SortBySample.NewDriver.R \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--images_path ${work_dir}/finalPlot/Evolution_Driver/ \
--info_file ${config_path}/tumor_normal.class.list \
--class_order_file ${config_path}/Class_order.list \
--class_order_sub_file ${config_path}/Class_order_sub.list \
--tp53_pre_file ${Images_path}/lollipop/TP53_NMU/TP53.PreCancerous.UniqueNormal.tsv \
--tp53_cancer_file ${Images_path}/lollipop/TP53_NMU/TP53.Cancerous.UniqueNormal.tsv 

##########################################
## 突变的共享及私有
clone_t=0.6
choose_rate=0
class_type_list=("IGC_ALL" "DGC_ALL" "IGC" "DGC" "IGC_DGC_IGC" "IGC_DGC_DGC")
for class_type in ${class_type_list[@]}
do
## 驱动基因的共享和私有情况
${Rscript} ${scripts_path}/plot/JudgeGeneDriverSharePrivate.DriverNew.R \
--muti_cancer ${maf_path}/All_GGA.cancer.maf \
--muti_pre ${maf_path}/All_GGA.precancer.maf \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.tsv \
--gene_list ${mutsig_check_path}/smg.list  \
--sample_info ${config_path}/tumor_normal.class.list \
--type ${class_type} \
--clone_t ${clone_t} \
--choose_rate ${choose_rate} \
--out_path ${work_dir}/finalPlot/Evolution_Driver/share_private
done

##########################################
## 棒棒糖图
gene_list=("MICAL2" "DNAH3")
for gene in ${gene_list[@]}
do
${Rscript} ${scripts_path}/finalPlot/Lollipop_variant.divide_IGC_DGC.R \
--gene ${gene} \
--pre_file ${maf_path}/All_GGA.precancer.maf \
--cancer_file ${maf_path}/All_GGA.cancer.maf \
--sample_info ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--gtf_file ${ref_path}/GTF/gencode.v19.annotation.exonNum.gtf \
--out_path ${Images_path}/lollipop/${gene}_NMU
done

## 替换转录本
for file in `ls ${Images_path}/lollipop/NRG1_NMU/`
do
sed -i "s/ENST00000520407/ENST00000287842/" ${Images_path}/lollipop/NRG1_NMU/${file}
done


##########################################
## 5例IGC和DGC均有样本的进化树
for Normal in `cat ${config_path}/tumor_normal.class.list | grep "IM + IGC + DGC" | awk -F'\t' '{print $2}' | sort -u`
do
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${Normal} | awk -F'\t' '{print $1}' | sort -u`
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/Evolution_Driver/${Normal}_mlhtree.pdf
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/Evolution_Driver/${Normal}_variants.csv
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/Evolution_Driver/${Normal}_Driver.pdf
done

## 这些基因的进化树
Variant_Types="Missense_Mutation|Nonsense_Mutation|Frame_Shift_Ins|Frame_Shift_Del|In_Frame_Ins|In_Frame_Del|Splice_Site|Nonstop_Mutation"
gene_list=("MICAL2" "DNAH3" "NRG1")
for gene in ${gene_list[@]}
do
## 判断IGC和DGC应该是自己进行判断
mkdir -p ${work_dir}/finalPlot/Evolution_Driver/${gene}
## 存在突变的样本
for sample in `cat ${MutationTime_path}/result/All_CCF_mutTime.tsv | grep -w ${gene} | grep -E -w ${Variant_Types} | awk -F'\t' '{print $1}' | sort -u`
do
Normal=`cat ${config_path}/tumor_normal.class.list | grep -w ${sample} | awk -F'\t' '{print $2}' | sort -u`
id=`cat ${config_path}/tumor_normal.class.list | grep -w ${sample} | awk -F'\t' '{print $1}' | sort -u`
## 链接进化树
ln -snf ${tree_path}/Tree_file/${Normal}_mlhtree.pdf ${work_dir}/finalPlot/Evolution_Driver/${gene}/
ln -snf ${tree_path}/Tree_file/${Normal}_variants.csv ${work_dir}/finalPlot/Evolution_Driver/${gene}/
## 链接驱动基因的CCF
ln -snf ${Images_path}/DriverEverySample/${id}_Driver.pdf ${work_dir}/finalPlot/Evolution_Driver/${gene}/${Normal}_Driver.pdf
done
done


####################################################################################
## 第六部分进化模式
####################################################################################
## 肿瘤异质性的计算
## 排除IGC和DGC均有的样本
## 计算IM_IGC和IM_DGC的瘤内异质性
${Rscript} ${scripts_path}/tree/ComputeHeterogeneity.OnlyHeterogeneity.R \
--muti_cancer ${maf_path}/All_GGA.cancer.maf \
--muti_pre ${maf_path}/All_GGA.precancer.maf \
--sample_info ${config_path}/tumor_normal.class.list \
--out_path ${work_dir}/finalPlot/Evolution_Mode/

## 以共享驱动突变定义两种亚型，判断瘤内异质性
${Rscript} ${scripts_path}/tree/ComputeHeterogeneity.TrunkDriver.R \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--gene_list ${Images_path}/selectGCClone/GCClone_gene.all_record.list \
--ith_file ${work_dir}/finalPlot/Evolution_Mode/ITH.compute.uniqueNormal.tsv \
--ith_sample_file ${work_dir}/finalPlot/Evolution_Mode/ITH.compute.allSample.tsv \
--sample_info ${config_path}/tumor_normal.class.list \
--out_path ${work_dir}/finalPlot/Evolution_Mode/

## 描述共享驱动亚型和非共享驱动亚型，8个关键驱动基因的分支情况
class_type_list=("IGC" "DGC")
for class_type in ${class_type_list[@]}
do
## 驱动基因的共享和私有情况
${Rscript_clusterProfiler} ${scripts_path}/finalPlot/JudgeGeneDriverTrunkDriver.R \
--muti_cancer ${maf_path}/All_GGA.cancer.maf \
--muti_pre ${maf_path}/All_GGA.precancer.maf \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.tsv \
--gene_list ${Images_path}/selectGCClone/GCClone_gene.all_record.list \
--sample_info ${config_path}/tumor_normal.class.list \
--type ${class_type} \
--trunk_file ${work_dir}/finalPlot/Evolution_Mode/ITH.combineNormal.IGC_DGC.TrunkDriver.tsv \
--out_path ${work_dir}/finalPlot/Evolution_Mode/
done

####################################################################################
## 第7部分进化时间
####################################################################################
## 判断进展时间
## 整理输入文件
## 1、胃癌私有的过客突变（Silent）数量
${Rscript} ${scripts_path}/evolutionTime/prepareInput.R \
--muti_cancer ${maf_path}/All_GGA.cancer.maf \
--muti_pre ${maf_path}/All_GGA.precancer.maf \
--sample_info ${config_path}/tumor_normal.class.list \
--out_path ${work_dir}/finalPlot/evolutionTime

## 突变率从1-10/per year，推测时间
${Rscript_evolutionTime} ${scripts_path}/evolutionTime/timing_summary.R \
--input_file ${work_dir}/finalPlot/evolutionTime/sample_mutNum.tsv \
--code_path ${scripts_path}/evolutionTime/ipmn-timing-master \
--plot_id_file ${config_path}/plotID.list \
--out_path ${work_dir}/finalPlot/evolutionTime

## 时间比较
## 1、IM进展为IGC的时间，IM进展为DGC的时间
## 2、发生Trunk的TP53、APC、CDH1、PIK3CA基因突变是否会加速IM进展为胃癌的时间
## 3、特定基因的组合
${Rscript} ${scripts_path}/evolutionTime/compareTime.R \
--ccf_file ${MutationTime_path}/result/All_CCF_mutTime.addShare.tsv \
--gene_list ${Images_path}/selectGCClone/GCClone_gene.all_record.list  \
--sample_info ${config_path}/tumor_normal.class.list \
--input_file ${work_dir}/finalPlot/evolutionTime/timing_molecular_clock.tsv \
--out_path ${work_dir}/finalPlot/evolutionTime

## 吸烟饮酒HP是否会加速IM进展为GC
${Rscript} ${scripts_path}/evolutionTime/compareTime.baseinfo.R \
--sample_info ${work_dir}/baseTable/STAD_Info.addBurden.MSI_MSS.addCNVType.tsv \
--input_file ${work_dir}/finalPlot/evolutionTime/CompareTrunkSMG.Time.tsv \
--out_path ${work_dir}/finalPlot/evolutionTime/baseinfo
